package com.hangzhou.xyj.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hangzhou.xyj.R;

import java.util.List;

/**
 * Created by neo.duan on 2016/6/6.
 * 编译信息的adapter
 */
public class BuildInfoAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{

    private Context mContext;
    private List<String> mBuildInfoList;

    public BuildInfoAdapter(Context context, List<String> buildInfoList) {
        this.mContext = context;
        this.mBuildInfoList = buildInfoList;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = View.inflate(mContext, R.layout.layout_build_info_item, null);
        return new BuildItemViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ((BuildItemViewHolder)holder).setData(mBuildInfoList.get(position));
    }

    @Override
    public int getItemCount() {
        if (mBuildInfoList == null) {
            return 0;
        }
        return mBuildInfoList.size();
    }

    class BuildItemViewHolder extends RecyclerView.ViewHolder {
        private TextView mTvBuildInfo;
        public BuildItemViewHolder(View itemView) {
            super(itemView);

            mTvBuildInfo = (TextView) itemView.findViewById(R.id.tv_build_info);
        }

        public void setData(String info) {
            mTvBuildInfo.setText(info);
        }
    }
}
